package com.shuaiche.yeguan.ui.login;

import android.os.Bundle;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.widget.ImageView;

import com.geetest.onelogin.OneLoginHelper;
import com.shuaiche.yeguan.R;
import com.shuaiche.yeguan.base.BaseActivity;
import com.shuaiche.yeguan.util.GlideUtil;

public class OneLoginDialogStyleActivity extends BaseActivity {
    private ImageView phoneImage;
    private boolean isDialog = false;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        getWindow().getDecorView().setSystemUiVisibility(
                View.SYSTEM_UI_FLAG_LIGHT_STATUS_BAR
        );

        OneLoginUtils oneLoginUtils = new OneLoginUtils(OneLoginDialogStyleActivity.this, oneLoginResult);
        getWindow().setBackgroundDrawable(getDrawable(R.drawable.bg_white));
        if (OneLoginHelper.with().isPreGetTokenResultValidate()) {
            oneLoginUtils.requestToken();
            return;
        } else {
            oneLoginUtils.requestToken();
            setContentView(R.layout.gt_demo_activity_onelogin_dialog_style);
        }

        phoneImage = findViewById(R.id.phone_iv);
        getWindow().setWindowAnimations(R.style.AnimBottom);

        getWindow().setLayout(WindowManager.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.WRAP_CONTENT);
        getWindow().getAttributes().gravity = Gravity.BOTTOM;

        GlideUtil.loadGifResource(this, R.drawable.gt_demo_getphone, phoneImage);
    }

    private OneLoginResult oneLoginResult = new OneLoginResult() {
        @Override
        public void onResult() {
            finish();
        }

        @Override
        public void onResult(int flag) {
            super.onResult(flag);
            onResult();
        }
    };


}
